/**
 * 双框架版本、单框架版本
 */
export enum SDKType {
  Double = 'Double',
  Single = 'Single',
}

/**
 * RuntimeOS
 */
export enum RuntimeOSType {
  HarmonyOS = 'HarmonyOS',
  OpenHarmony = 'OpenHarmony',
}

/**
 * 模型，Stage模型和 FA模型
 */
export enum APIType {
  STAGE = 'stageMode',
  FA = 'faMode',
}

/**
 * API版本，4到16
 */
export enum APIVersion {
  API4 = 'API4',
  API5 = 'API5',
  API6 = 'API6',
  API7 = 'API7',
  API8 = 'API8',
  API9 = 'API9',
  API10 = 'API10',
  API11 = 'API11',
  API12 = 'API12',
  API13 = 'API13',
  API14 = 'API14',
  API16 = 'API16',
  API18 = 'API18'
}

export const CURRENT_HMOS_API = APIVersion.API18;

const apiVersionConvertMap = {
  API4: { [RuntimeOSType.HarmonyOS]: '', [RuntimeOSType.OpenHarmony]: '4' },
  API5: { [RuntimeOSType.HarmonyOS]: '', [RuntimeOSType.OpenHarmony]: '5' },
  API6: { [RuntimeOSType.HarmonyOS]: '', [RuntimeOSType.OpenHarmony]: '6' },
  API7: { [RuntimeOSType.HarmonyOS]: '', [RuntimeOSType.OpenHarmony]: '7' },
  API8: { [RuntimeOSType.HarmonyOS]: '', [RuntimeOSType.OpenHarmony]: '8' },
  API9: { [RuntimeOSType.HarmonyOS]: '', [RuntimeOSType.OpenHarmony]: '9' },
  API10: { [RuntimeOSType.HarmonyOS]: '"4.0.0(10)"', [RuntimeOSType.OpenHarmony]: '10' },
  API11: { [RuntimeOSType.HarmonyOS]: '"4.1.0(11)"', [RuntimeOSType.OpenHarmony]: '11' },
  API12: { [RuntimeOSType.HarmonyOS]: '"5.0.0(12)"', [RuntimeOSType.OpenHarmony]: '12' },
  API13: { [RuntimeOSType.HarmonyOS]: '"5.0.1(13)"', [RuntimeOSType.OpenHarmony]: '13' },
  API14: { [RuntimeOSType.HarmonyOS]: '"5.0.2(14)"', [RuntimeOSType.OpenHarmony]: '14' },
  API16: { [RuntimeOSType.HarmonyOS]: '"5.1.0(16)"', [RuntimeOSType.OpenHarmony]: '16' },
  API18: { [RuntimeOSType.HarmonyOS]: '"5.1.0(18)"', [RuntimeOSType.OpenHarmony]: '18' }
};

export const sdkPathConvertMap: Partial<{ [key in APIVersion]: string }> = {
  [APIVersion.API10]: 'HarmonyOS-NEXT-DP0',
  [APIVersion.API11]: 'HarmonyOS-NEXT-DP1',
  [APIVersion.API12]: 'default',
  [APIVersion.API13]: 'default',
  [APIVersion.API14]: 'default',
  [APIVersion.API16]: 'default',
  [APIVersion.API18]: 'default'
};

export function compileVersion(version: APIVersion, osType: RuntimeOSType): string {
  if (osType === RuntimeOSType.HarmonyOS) {
    return apiVersionConvertMap[CURRENT_HMOS_API][osType];
  }
  return apiVersionConvertMap[version][osType];
}

export function compileApiNumber(version: APIVersion, osType: RuntimeOSType): number {
  const compileSdkVersion = compileVersion(version, osType);
  return parseInt(compileSdkVersion.substring(compileSdkVersion.indexOf('(') + 1, compileSdkVersion.indexOf(')')));
}

/**
 * 工程类型，Application 和 Atomic Service
 */
export enum AbilityType {
  Application = 'Application',
  AtomicService = 'AtomicService',
}

/**
 * 是否签名
 */
export enum SignType {
  Sign = 'sign',
  NoSign = 'no-sign',
}

/**
 * 是否可用
 */
export enum IsEnable {
  Enable = 'enable',
  DisAble = 'disable',
}

/**
 * 模块的模板类型
 */
export enum ModuleTemplateType {
  EmptyAbility = 'application',
  LiteEmptyAbility = 'liteApplication',
  ListAbility = 'listApplication',
  NativeC = 'nativeApplication',
  SharedLibrary = 'shareLibrary',
  SharedLibraryWithC = 'shareNativeCLibrary',
  StaticLibrary = 'staticLibrary',
  JsStaticLibrary = 'jsStaticLibrary',
  StaticLibraryWithC = 'staticNativeCLibrary',
  VisualLibrary = 'visualLibrary',
  FeatureEmptyAbility = 'feature',
}

/**
 * 模块类型，entry、feature、shared、har
 */
export enum ModuleType {
  Hap = 'hap',
  Hsp = 'hsp',
  Har = 'har',
}

/**
 * 模板类型和模块类型的对应关系
 */
export const ModuleTypeMap = {
  [ModuleTemplateType.EmptyAbility]: ModuleType.Hap,
  [ModuleTemplateType.LiteEmptyAbility]: ModuleType.Hap,
  [ModuleTemplateType.ListAbility]: ModuleType.Hap,
  [ModuleTemplateType.NativeC]: ModuleType.Hap,
  [ModuleTemplateType.SharedLibrary]: ModuleType.Hsp,
  [ModuleTemplateType.SharedLibraryWithC]: ModuleType.Hsp,
  [ModuleTemplateType.VisualLibrary]: ModuleType.Hsp,
  [ModuleTemplateType.StaticLibrary]: ModuleType.Har,
  [ModuleTemplateType.StaticLibraryWithC]: ModuleType.Har,
  [ModuleTemplateType.FeatureEmptyAbility]: ModuleType.Hap,
  [ModuleTemplateType.JsStaticLibrary]: ModuleType.Har,
};

/**
 * 语言类型，Java/Js/ArkTs
 */
export enum LanguageType {
  Java = 'Java',
  Js = 'Js',
  ArkTs = 'ArkTs',
}

/**
 * 测试任务状态， 'notExecuted' | 'running' | 'pass' | 'fail'
 */
export enum TaskStatus {
  NotExecuted = 'notExecuted',
  Running = 'running',
  Pass = 'pass',
  Fail = 'fail',
}

/**
 * 用例级别
 */
export enum CaseLevel {
  L0 = 'l0',
  L1 = 'l1',
  L2 = 'l2',
  L3 = 'l3',
  DTS = 'dts',
  AR = 'ar',
}

/**
 * node路径
 */
export const nodePath = process.env.NODEJS_PATH;

/**
 * 单框架SDK路径
 */
export const singleSdkPath = process.env.DEVECO_SDK_HOME;

/**
 * 双框架SDK路径
 */
export const doubleSdkPath = process.env.DOUBLE_SDK_PATH;

export const HVIGOR_USER_HOME_DIR_NAME = '.hvigor';
